import Vue from 'vue';
import VueRouter from 'vue-router';

Vue.use(VueRouter);
const routes = [
    {
        path: '/home',
        name: 'home',
        redirect: ()=>({name: 'environment'}),
        component: () => import('@/views/Home'),
        children: [
            {
                path: 'environment',
                name: 'environment',
                component: () => import('@/views/Environment')
            },
            {
                path: 'notice',
                name: 'notice',
                component: () => import('@/views/Notice')
            }
        ]
    },
    {
        path: '/rent',
        name: 'rent',
        component: () => import('@/views/Rent')
    },
    {
        path: '/login',
        name: 'login',
        component: () => import('@/views/Login')
    },
    {
        path:'/register',
        name:'register',
        component: () => import('@/views/Register')
    },
    {
        path:'/forget',
        name:'forget',
        component: () => import('@/views/Forget')
    },
    {
        path: '/personal',
        name: 'personal',
        redirect: ()=>({name: 'message'}),
        component: () => import('@/views/Personal'),
        children: [
            {
                path: 'message',
                name: 'message',
                component: () => import('@/views/Message')
            },
            {
                path: 'dorm',
                name: 'dorm',
                component: () => import('@/views/DormManage')
            },
            {
                path: 'query',
                name: 'query',
                component: () => import('@/views/TransactionQuery')
            },
            {
                path: 'setting',
                name: 'setting',
                component: () => import('@/views/setting')
            }
        ]
    },
    {
        path: '/propertyDetail',
        name: 'propertyDetail',
        component: () => import('@/views/PropertyDetail')
    },
    {
        path: '/formApplication',
        name: 'formApplication',
        component: () => import('@/views/FormApplication')
    },
    {
        path: '/backStage',
        name: 'backStage',
        redirect: ()=>({name: 'noticeManage'}),
        component: () => import('@/views/BackStage'),
        children: [
            {
                path: '/noticeManage',
                name: 'noticeManage',
                component: () => import('@/views/NoticeManage')
            },
            {
                path: '/archivesManage',
                name: 'archivesManage',
                component: () => import('@/views/ArchivesManage')
            },
            {
                path: '/verifyManage',
                name: 'verifyManage',
                component: () => import('@/views/VerifyManage')
            },
            {
                path: '/graphicList',
                name: 'graphicList',
                component: () => import('@/views/GraphicList')
            },
        ]
    },
    {
        path: '/infoManage',
        name: 'infoManage',
        component: () => import('@/views/InfoManage')
    },
    {
        path: '*',
        component: () => import('@/views/NotFound')
    }
]

const RouterConfig = {
    // 使用HTML5的历史路由模式
    mode: 'history',
    routes
}

const router = new VueRouter(RouterConfig);

export default router;
